const express = require("express");
const router = express.Router();

const {
    perpetualData,
    perpetualhistoryPosList,
    perpetualAllDataList,
    inStockTransacRobot
} = require("../../data/mockData.js");

const { getBalance } = require('../units/index.js')

// 查询交易页面数据
router.get("/data/basic/perpetual", (req, res) => {
    //   console.log(req.query, "req");
    res.success({ data: perpetualData, message: "perpetual数据查询成功" });
});

// 仓位
router.get("/perpetual/position/list", async (req, res) => {
    // console.log(req.query, "req");
    const data = await getBalance(req.query.address, req.query.page, req.query.size)

    res.success({ data: data.accountTransactions, message: `账户的交易数据查询成功！` });
    // res.success({
    //     data: perpetualPositionList,
    // });
});

// 历史仓位
router.get("/perpetual/history/position", (req, res) => {
    // console.log(req.query, "req");

    res.success({
        data: perpetualhistoryPosList,
    });
});

// 当前委托
router.get("/perpetual/current/commission", (req, res) => {
    // console.log(req.query, "req");

    res.success({
        data: perpetualAllDataList,
    });
});

// 历史委托
router.get("/perpetual/commission/history", (req, res) => {
    // console.log(req.query, "req");

    res.success({
        data: perpetualAllDataList,
    });
});

// 成交记录
router.get("/perpetual/transaction/record", (req, res) => {
    // console.log(req.query, "req");

    res.success({
        data: perpetualAllDataList,
    });
});

// 资金流水
router.get("/perpetual/capital/flow", (req, res) => {
    // console.log(req.query, "req");

    res.success({
        data: perpetualAllDataList,
    });
});

// 交易机器人
router.get("/perpetual/transaction/robot", (req, res) => {
    // console.log(req.query, "req");

    res.success({
        data: inStockTransacRobot,
    });
});






// // 交易
// router.post("/buy/sell/alpha", (req, res) => {
//     console.log(req.body, "交易请求数据");

//     // 模拟交易逻辑
//     res.success({ message: "alpha交易成功" });
// });

module.exports = router;
